import { State } from "framework/FSM/AState";
import { ActionArgHelper } from "../../ActionManager/ActionArgHelper";
 

/*
给PC 续命
*/
export class State_PCRenew<T extends IStateArg<PowerCreep>>  extends State<T>
{

    public  getActions(arg:T):Action[]
    {
        const core = arg.entity.getEntity("CoreEntity");
        if( core.PowerSpawn)
        {
            if(arg.entity.pos.distance( core.PowerSpawn.pos)>1)
            {
                // const motoarg:IMoveArg={creepid:"" as Id<Creep>,pos: core.PowerSpawn.pos,range:1,opt:{}};
                // arg.entity.moveTo(motoarg);
                return [ActionArgHelper.actionMoveto(arg.entity,{pos:  core.PowerSpawn.pos,range:1},{})]
            }
            else
            {
                arg.entity.renew( core.PowerSpawn);
            }
        }
        else
        {
            arg.entity.log('warn',`此房间 ${ arg.entity.memory.OwnerRoom} 没有powerSpawn` );
            // lobal.Log.Error(`此房间 ${ arg.entity.MountRoom} 没有powerSpawn`);
        }
        return [];
    }

}
